Xbasic

SQL::StatementExecute Method

Syntax

Result_Flag as L = Execute([SQLConnection as SQL::Connection | SQLConnectionString as C] [, Arguments as SQL::Arguments | Arguments as C])

Arguments

Result_Flag

TRUE (.T.) if the operation was successful; otherwise FALSE (.F.).

SQLConnection

Optional. A SQL::Connection object created with a DIM statement.

SQLConnectionString

Optional. A connection string.

Arguments

SQL::Arguments | Arguments

Description

Execute the current statement using the current or passed connection. Optionally providing argument values as an object or as XML.

Discussion

The Execute() method accepts an optional SQL::Connection object or connection string and executes the SQL statement in the SQL::Statement.SQLStatement property. Note: Argument values are merged with those already set on the query.

Dimension the variables. This script will need SQL::Connection and SQL::Statement objects to delete the data.

dim conn as SQL::Connection
dim stat as SQL::Statement
dim connString as C
dim sql_delete as C

Assign values to the character variables.

connString = "{A5API='Access', FileName='c:\program files\a5v7\mdbfiles\alphasports.mdb'}"

Note that the DELETE command uses the SubString()portability function as part of the WHERE clause.

sql_delete = "DELETE FROM Customer_copy WHERE substring(lastname,1,1) = 'A'"

Establish the connection.

IF .not. conn.open(connString) THEN
    end
END IF

Check the SQL DELETE statement.

IF .not. stat.parse(sql_delete) THEN
    ui_msg_box("Error", stat.callresult.text)
    end
END IF

Execute the SQL DELETE statement.

IF .not. stat.execute(conn)
    ui_msg_box("Error", stat.callresult.text)
    end
END IF

See Also